package com.climb.spingcloud.controller;


import com.climb.spingcloud.base.R;
import com.climb.spingcloud.convert.UserConvert;
import com.climb.spingcloud.dto.UserDto;
import com.climb.spingcloud.entity.User;
import com.climb.spingcloud.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author filteraid
 * @since 2021-08-02
 */
@RestController
@RequestMapping("/users")
public class UserController {
    @Autowired
    private UserService userService;
    @ResponseStatus(HttpStatus.OK)
    @GetMapping("/{id}")
    public R<UserDto> getById(@PathVariable("id")Long id){
        User user=userService.getById(id);
        UserDto userDto= UserConvert.INSTANCE.entity2dto(user);
        return R.success().data(userDto);
    }

}

